package gui;

import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import com.jgoodies.forms.layout.FormLayout;
import com.jgoodies.forms.layout.ColumnSpec;
import com.jgoodies.forms.factories.FormFactory;
import com.jgoodies.forms.layout.RowSpec;
import javax.swing.JScrollPane;
import javax.swing.JTree;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import javax.swing.JLabel;
import javax.swing.JMenuBar;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import java.awt.Toolkit;
import javax.swing.UIManager;

public class StoryLineAppGUI implements PropertyChangeListener {

	public JFrame frmStoryline;
	
	JPanel panel = new JPanel();
	public static JScrollPane scrollTree = new JScrollPane();
	JTree treeStory = new JTree();
	
	public static JPanel panelContent = new JPanel();
	public static JPanel panelSide = new JPanel();
	public static JLabel lblStatusOutput = new JLabel("Ready");
	public static JMenuBar menuBar = new JMenuBar();
	public static JMenu mnFile = new JMenu("File");
	public static JMenu mnStory = new JMenu("Story");
	public static JMenu mnExtras = new JMenu("Extras");
	public static JMenu menuHelp = new JMenu("?");
	public static JMenuItem mntmInfo = new JMenuItem("Info");
	public static JMenuItem mntmDonate = new JMenuItem("Donate");
	public static JMenuItem mntmWebsite = new JMenuItem("Website");
	public static JMenuItem mntmHelp = new JMenuItem("Help");
	public static JMenuItem mntmExit = new JMenuItem("Exit");
	public static JMenuItem mntmSettings = new JMenuItem("Application Settings");
	public static JMenuItem mntmManageStories = new JMenuItem("Manage Stories");
	public static JMenuItem mntmStatistics = new JMenuItem("Statistics");
	public static JMenuItem mntmAuthor = new JMenuItem("Author's Profile");
	public static JMenuItem mntmEditors = new JMenuItem("Configure Editor");
	public static JMenu menuNew = new JMenu("New");
	public static JMenuItem mntmNewStory = new JMenuItem("Story");
	public static JMenuItem mntmNewChapter = new JMenuItem("Chapter");
	public static JMenuItem mntmNewScene = new JMenuItem("Scene");
	public static JMenuItem mntmNewCharacter = new JMenuItem("Character");
	public static JMenuItem mntmNewLocation = new JMenuItem("Location");
	public static JMenuItem mntmNewPlot = new JMenuItem("Plot");
	public static JMenu mnSendTo = new JMenu("Send To");
	public static JMenu mnImport = new JMenu("Import");
	public static JMenu mnExport = new JMenu("Export");
	public static JMenuItem mntmFromFile = new JMenuItem("File");
	public static JMenuItem mntmDatabase = new JMenuItem("Database");
	public static JMenuItem mntmFile = new JMenuItem("File");
	public static JMenuItem mntmDatabase_1 = new JMenuItem("Database");
	public static JMenuItem mntmEmail = new JMenuItem("Email");
	public static JMenuItem mntmShare = new JMenuItem("Share");
	public static JMenuItem mntmPrinter = new JMenuItem("Printer");
	public static JMenu mnChapter = new JMenu("Chapter");
	public static JMenu mnScene = new JMenu("Scene");
	public static JMenu mnCharacter = new JMenu("Character");
	public static JMenu mnLocation = new JMenu("Location");
	public static JMenu mnFaction = new JMenu("Faction");
	public static JMenu mnPlot = new JMenu("Plot");
	public static JMenu mnNotes = new JMenu("Notes");

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					StoryLineAppGUI window = new StoryLineAppGUI();
					window.frmStoryline.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the application.
	 */
	public StoryLineAppGUI() {
		initialize();
	}

	/**
	 * Initialize the contents of the frame.
	 */
	
	int x = 475;
	private final JMenu mnView = new JMenu("View");
	private final JMenuItem mntmHideMenu = new JMenuItem("Hide Details");
	

	
	private void initialize() {
		frmStoryline = new JFrame();
		//frmStoryline.setIconImage(Toolkit.getDefaultToolkit().getImage(""));
		frmStoryline.addPropertyChangeListener(this);
		
		frmStoryline.setTitle("StoryLine");
		frmStoryline.setBounds(100, 100, 900, 645);
		frmStoryline.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frmStoryline.getContentPane().setLayout(new BorderLayout(0, 0));
		
		JPanel mainPanel = new JPanel();
		frmStoryline.getContentPane().add(mainPanel, BorderLayout.CENTER);
		mainPanel.setLayout(new FormLayout(new ColumnSpec[] {
				ColumnSpec.decode("10px"),
				ColumnSpec.decode("200px"),
				ColumnSpec.decode("5px"),
				ColumnSpec.decode("left:default:grow"),
				ColumnSpec.decode("5px"),
				ColumnSpec.decode("200px"),
				ColumnSpec.decode("10px"),},
			new RowSpec[] {
				RowSpec.decode("501px:grow"),
				FormFactory.RELATED_GAP_ROWSPEC,
				RowSpec.decode("25px"),}));
		mainPanel.add(panel, "2, 1, fill, fill");
		
		panel.setLayout(new BorderLayout(0, 0));
		scrollTree.setViewportBorder(null);
		
		panel.add(scrollTree);
		treeStory.setBorder(null);
	
		panelContent.setBorder(null);
		panelContent.setBackground(UIManager.getColor("Button.background"));
		
		mainPanel.add(panelContent, "4, 1, fill, fill");
		panelSide.setBorder(null);
		panelSide.setBackground(UIManager.getColor("Button.background"));
		
		mainPanel.add(panelSide, "6, 1, fill, fill");
		panelSide.setLayout(new BorderLayout(0, 0));
		mainPanel.add(lblStatusOutput, "2, 3, 5, 1");
		
		frmStoryline.setJMenuBar(menuBar);
		menuBar.add(mnFile);
		mnFile.add(menuNew);
		menuNew.add(mntmNewStory);
		menuNew.add(mntmNewChapter);
		menuNew.add(mntmNewScene);
		menuNew.add(mntmNewCharacter);
		menuNew.add(mntmNewLocation);
		menuNew.add(mntmNewPlot);
		mnFile.add(mnSendTo);
		mnSendTo.add(mntmEmail);
		mnSendTo.add(mntmShare);
		mnSendTo.add(mntmPrinter);
		mnFile.add(mnImport);
		mnImport.add(mntmFromFile);
		mnImport.add(mntmDatabase);
		mnFile.add(mnExport);
		mnExport.add(mntmFile);
		mnExport.add(mntmDatabase_1);
		mnFile.add(mntmExit);
		menuBar.add(mnStory);
		mnStory.add(mntmManageStories);
		menuBar.add(mnChapter);
		menuBar.add(mnScene);
		menuBar.add(mnCharacter);
		menuBar.add(mnLocation);
		menuBar.add(mnFaction);
		menuBar.add(mnPlot);
		
		menuBar.add(mnNotes);
		
		menuBar.add(mnView);
		
		mnView.add(mntmHideMenu);
		menuBar.add(mnExtras);
		mnExtras.add(mntmAuthor);
		mnExtras.add(mntmStatistics);
		mnExtras.add(mntmEditors);
		mnExtras.add(mntmSettings);
		menuBar.add(menuHelp);
		menuHelp.add(mntmHelp);
		menuHelp.add(mntmWebsite);
		menuHelp.add(mntmDonate);
		menuHelp.add(mntmInfo);
		
		panelContent.setLayout(new BorderLayout(0, 0));
		
	}

	@Override
	public void propertyChange(PropertyChangeEvent arg0) {
		// TODO Auto-generated method stub
		
	}

}
